<?php
@session_start();
 echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';

/*
 *  A Part of snock project
 *   Author king-of-war
 * Last modified 2009-4-27
 *
 */
/*
 *   count add moudle
 */
$root_path = '../';
include_once $root_path . 'admin/smarty_config.php';
include_once $root_path . 'admin/class/count.class.php';
include_once $root_path . 'admin/class/count_cfg.class.php';
include_once $root_path . 'admin/class/fun_common.php';

/*
 *
 * check identify
 */
include_once $root_path.'admin/class/verify.class.php';
$a=new verify($root_path);
$a->identity_check(2);

/*
 * init the class about count
 */
$count = new count($root_path);
$fun = new fun_common($root_path);



/*
 * count date get
 */
$total = $fun->get_part('count', '');
$co = $count->count_read('');
$ips = array ();

for ($i = 0; $i < count($co); $i++) {
	$ips[$i] = $co[$i]->get_ip();

}
/*
 * anlysis ips
 */
$a=0;

$total=count($ips);

 for ($i = 0; $i < count($ips); $i++) {
	if ($ips[$i] == $ips[$i+1]) {

	}else{
		$ip_a[$a]['count']=$i;
		$ip_a[$a]['ip']=$ips[$i];
       $a++;
	}
}

/*
 * anlysis ip
 */
$max=count($ip_a);

for($i=0;$i<$max;$i++){
	$an[$i]['num']=$ip_a[$i]['count']-$ip_a[$i-1]['count'];
	$an[$i]['cen']=$an[$i]['num']/$total*600;
	$an[$i]['ip']=$ip_a[$i]['ip'];

}


/*
 * set template
 */
$smarty->assign("con",$an);
$smarty->assign("total",$total);
$smarty->display("count_analysis.html");
?>
